<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <input type="text" name="username" value="hello">
</body>

<script>
    var username = document.querySelector('[name="username"]');

    // 输入框对象的 value 就是用户输入的值
    console.log(username);

    // 对输入框的输入事件进行监听
    username.oninput = function() {
        console.log('检测到用户在输入');
    }
</script>
</html>